package com.ctshk.sapp.system.controller;

import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.model.PageResponse;
import com.ctshk.common.model.TokenUser;
import com.ctshk.common.web.support.BaseController;
import com.ctshk.rpc.system.dto.MainDataCollectionDetailListDTO;
import com.ctshk.rpc.system.dto.MainDataCollectionTouristTypeDTO;
import com.ctshk.rpc.system.req.*;
import com.ctshk.rpc.system.service.IMainDataCollectionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 *
 * </p>
 *
 * @author xuhui
 * @since 1/26/2021
 */

@Api(value="代收费用", tags="主数据代收费用")
@RestController
@RequestMapping("/main/data/collection")
public class MainDataCollectionController extends BaseController {

    @DubboReference
    private IMainDataCollectionService mainDataCollectionService;


    @ApiOperation(value="代收费用明细列表", notes="代收费用明细列表主数据")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.QUERY, operTitle = "代收费用明细", operDesc = "代收费用明细主数据")
    @PostMapping("/details")
    public Result<PageResponse<MainDataCollectionDetailListDTO>> listCollectionTouristType(@RequestBody @Valid MainDataCollectionDetailListReq MainDataCollectionDetailListReq){
        return Result.success(mainDataCollectionService.list(MainDataCollectionDetailListReq));
    }

    @ApiOperation(value="增加代收费用项", notes="增加代收费用项主数据")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.ADD, operTitle = "增加代收费用项", operDesc = "增加代收费用项主数据")
    @PostMapping("/add")
    public Result addCollectionTouristType(@RequestBody MainDataCollectionDetailAddReq req){
        return  mainDataCollectionService.add(req,getCurrentUser(getRequest()));
    }

    @ApiOperation(value="修改代收费用项", notes="修改代收费用项主数据")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.UPDATE, operTitle = "修改代收费用项", operDesc = "修改代收费用项主数据")
    @PostMapping("/update")
    public Result editCollectionTouristType(@RequestBody MainDataCollectionDetailUpdateReq mainDataCollectionDetailUpdateReq){

        return  mainDataCollectionService.update(mainDataCollectionDetailUpdateReq,getCurrentUser(getRequest()));

    }

    @ApiOperation(value="删除代收费用项", notes="删除代收费用项主数据")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.DELETE, operTitle = "删除代收费用项", operDesc = "删除代收费用项主数据")
    @GetMapping("/delete/{collectionDetailsId}")
    public Result deleteCollectionTouristType(@PathVariable("collectionDetailsId")  Long collectionDetailsId){

        return  mainDataCollectionService.delete(collectionDetailsId,getCurrentUser(getRequest()));
    }

    @ApiOperation(value="修改代收费用项状态", notes="修改代收费用项状态主数据")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.UPDATE, operTitle = "修改代收费用项状态", operDesc = "修改代收费用项状态主数据")
    @PostMapping("/update/status")
    public Result modifyCollectionTouristType(@RequestBody MainDataCollectionDetailUpdateStatusReq mainDataCollectionDetailUpdateStatusReq){

        return  mainDataCollectionService.modifyStatus(mainDataCollectionDetailUpdateStatusReq,getCurrentUser(getRequest()));
    }

    @ApiOperation(value="查询代收费用项", notes="查询代收费用项主数据单条数据")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.QUERY, operTitle = "查询代收费用项", operDesc = "查询代收费用项主数据")
    @PostMapping("/query")
    public Result<List<MainDataCollectionTouristTypeDTO>> detail(@RequestBody MainDataCollectionOneDetailReq mainDataCollectionOneDetailReq){
        return  mainDataCollectionService.detail(mainDataCollectionOneDetailReq,getCurrentUser(getRequest()));
    }



}